package web;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import server.UserRepository;

import model.User;

@Path("/rest/user")
public class UserController
{
	private final UserRepository repository = new UserRepository();
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON})    
	@Path("/post")
	public String createUser(User user)
	{
		repository.create(user);
		return "success";
	}
	
	@GET
	@Produces({MediaType.APPLICATION_JSON})
	@Path("/get/{userID}")
	public User fetchUser(@PathParam("userID") String userID)
	{
		return repository.getById(userID);
	}	
}
